package com.gxuwz.easyschool.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.gxuwz.easyschool.R;
import com.gxuwz.easyschool.holder.SystemNoticeHolder;

public class SystemNoticeAdapter extends BaseAdapter {
    private String[] titles = {"一卡通充值","一卡通充值","一卡通充值"};
    private String[] notice_types = {"系统通知","系统通知","系统通知"};
    private String[] pay_types = {"农行支付，支付成功","农行支付，支付成功","农行支付，支付成功"};
    private String[] notice_moneys = {"￥150","￥50","￥220"};
    private String[] notice_times = {"10分钟前","23小时前","2024-4-23"};
    private Context context;
    public SystemNoticeAdapter(Context context){
        this.context = context;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public Object getItem(int position) {
        return titles[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SystemNoticeHolder systemNoticeHolder = null;
        if(convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.system_notice_list,null);
            systemNoticeHolder = new SystemNoticeHolder();
            systemNoticeHolder.setNotice_title(convertView.findViewById(R.id.notice_title));
            systemNoticeHolder.setNotice_type(convertView.findViewById(R.id.notice_type));
            systemNoticeHolder.setPay_type(convertView.findViewById(R.id.pay_type));
            systemNoticeHolder.setNotice_money(convertView.findViewById(R.id.notice_money));
            systemNoticeHolder.setNotice_time(convertView.findViewById(R.id.notice_time));
            if (position == 0){
                systemNoticeHolder.setNotice_pic(convertView.findViewById(R.id.notice_pic));
            }
            convertView.setTag(systemNoticeHolder);
        } else {
            systemNoticeHolder = (SystemNoticeHolder) convertView.getTag();
        }
        systemNoticeHolder.getNotice_title().setText(titles[position]);
        systemNoticeHolder.getNotice_type().setText(notice_types[position]);
        systemNoticeHolder.getPay_type().setText(pay_types[position]);
        systemNoticeHolder.getNotice_money().setText(notice_moneys[position]);
        systemNoticeHolder.getNotice_time().setText(notice_times[position]);
        if (position == 0){
            systemNoticeHolder.getNotice_pic().setBackgroundResource(R.drawable.new_icon);
        }
        return convertView;
    }
}
